/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hciproject;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

/**
 *
 * @author Alerk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        String[] fileName = new String[4];
        fileName[0] = "./data/test_frontt.dat";
        fileName[1]="./data/test_frontsw2.dat";
        fileName[2] = "./data/test_backt.dat";
        fileName[3] = "./data/test_backsw.dat";
        
        // Read from files
        int[] result = new int[4];
        for(int i=0;i<4;i++)
        {
            try{
                FileInputStream in = new FileInputStream(fileName[i]);
                BufferedReader buff = new BufferedReader(new InputStreamReader(in));
                String strLine;
                int l = 450;
                float[]roll = new float[l];
                float[]pitch = new float[l];
                float[]yaw = new float[l];

                int counter = 0;
                while((strLine=buff.readLine())!=null && counter <l)
                {
                    /*if(counter<100)
                    {
                        counter++;
                        continue;
                    }
                    else*/
                    {
                        String[]temp = strLine.split(" ");                        
                        roll[(counter)%l] = Integer.parseInt(temp[1]);
                        pitch[(counter)%l] = Integer.parseInt(temp[2]);
                        yaw[(counter)%l] = Integer.parseInt(temp[3]);
                        //if(i==3)
                        //    System.out.println(temp[3]);
                        counter++;
                    }
                }
                System.out.println(fileName[i]);
                BusinessFunction.testValue(roll, pitch, yaw, 50);
                BusinessFunction.recognize(roll, pitch, yaw, 50);

                in.close();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
            float[] test = {466,
484,
493,
510,
513,
509,
509,
509,
499,
494,
498,
496,
497,
498,
499,
500,
499,
499,
499,
503,
506,
509,
508,
506,
507,
512,
514,
510,
507,
502,
526,
410,
507,
503,
510,
511,
509,
512,
509,
502,
494,
492,
492,
500,
499,
502,
503,
501,
499,
502
            };
            //System.out.println(BusinessFunction.variance(test, 50));
        }


        // Give the action
    }

}
